package cn.szx.boot.cms.configuration;

import cn.szx.boot.cms.interceptor.SessionInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 登录拦截器配置
 * @author jiangyl@szixing.cn
 * @date 2018/4/17 0017 下午 4:46
 * @visor
 */
@Configuration
public class SessionConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new SessionInterceptor()).addPathPatterns("/admin/**");//后台管理需校验是否登录。
    }

    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/_szx/resource/**").addResourceLocations("classpath:/static/");
    }
}
